<?php

namespace lxs\aliyun;

use Illuminate\Support\Facades\Storage;

class OssStorage
{

    public function Uploads($file, $path='images')
    {
        if (!is_file($file)) {
            return false;
        }
        $storage = Storage::disk('aliyunoss');

        $filename = date('ymdHis') . rand(1000, 9999) . '.' . $file->extension();

        $storage->putFileAs($path, $file, $filename);

        return str_replace('https://', 'https://' . env('ALIYUN_BUCKET') . '.', $storage->url($path . '/' . $filename));
    }

}
